Skip to content

Headers: allow to drop sensitive and custom ones#3

Merged
fgiudici merged 6 commits intomainfrom
issue1
Feb 13, 2026
Merged

Headers: allow to drop sensitive and custom ones#3
fgiudici merged 6 commits intomainfrom
issue1

Conversation

@fgiudici
Copy link
Copy Markdown
Owner

When publishing headertrace behind an API Gateway some HTTP Headers meant for internal usage are added during the HTTP request routing. Those headers can reveal sensitive details of the internal infrastructure.
While revealing those headers is exactly the goal of headertrace, returning them to each client request could pose security issues if the HTTP endpoint is widely reachable.
This PR adds a boolean option to redact known sensitive headers ('-P' to enable privacy mode) and another one ('-D`) to allow dropping custom headers.
When dropped, the headers are logged (at the debug level) to still allow inspecting and debugging HTTP headers transformations.

Fixes #1

When publishing headertrace behind an API Gateway some HTTP Headers ment
for internal usage are added during the HTTP request routing. Those
headers can reveal sensitive detail of the internal infrastructure.
While revealing those headers is part of the goal of headertrace,
returning them to each client request could pose security issues.
This commit adds an option to redact known sensitive headers and another
one to allow dropping custom headers.
When dropped, the headers are logged at the debug level.

Fixes #1

Signed-off-by: Francesco Giudici <dev@foggy.day>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configurable header redaction to headertrace so it can be safely exposed behind API gateways/CDNs without echoing potentially sensitive infrastructure headers back to clients (Fixes #1).

Changes:

  • Extend hdrs.ToMap to support dropping an explicit list of headers and an optional “privacy mode” that removes Cloudflare + X-Forwarded-* headers.
  • Add CLI flags -P/--privacy and -D/--drop-header and wire them through the server handler.
  • Log dropped headers at debug level for troubleshooting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
pkg/headers/headers.go Adds drop-header filtering + privacy-mode filtering when converting http.Header to a map.
cmd/cmd.go Introduces new CLI flags and passes them into request header echoing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/headers/headers.go Outdated
Comment thread pkg/headers/headers.go Outdated
Comment thread pkg/headers/headers.go Outdated
Comment thread pkg/headers/headers.go
Comment thread cmd/cmd.go Outdated
fgiudici and others added 5 commits February 13, 2026 10:19
Spotted by Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Francesco Giudici <fgiudici@foggy.day>
Also add general description and binary version to the help.

Signed-off-by: Francesco Giudici <dev@foggy.day>
Signed-off-by: Francesco Giudici <dev@foggy.day>
Signed-off-by: Francesco Giudici <dev@foggy.day>
Signed-off-by: Francesco Giudici <dev@foggy.day>
@fgiudici fgiudici merged commit 2588b85 into main Feb 13, 2026
1 check passed
@fgiudici fgiudici deleted the issue1 branch February 13, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

headertrace may expose sensitive data of the iinternal infrastructure

2 participants